home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
c
/
ctags.lha
/
ctags-3.0.3
/
options.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-02-17
|
44KB
|
1,511 lines
/*****************************************************************************
* $Id: options.c,v 7.1 1998/12/07 01:38:00 darren Exp $
*
* Copyright (c) 1996-1998, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
* GNU General Public License.
*
* This module contains functions to process command line options.
*****************************************************************************/
/*============================================================================
= Include files
============================================================================*/
#include "general.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h> /* to declare malloc(), realloc() */
#endif
#include <string.h>
#include <stdio.h>
#include <ctype.h> /* to declare toupper() */
#include "ctags.h"
#define OPTION_WRITE
#include "options.h"
#include "main.h"
#include "debug.h"
/*============================================================================
= Defines
============================================================================*/
#define INVOCATION "Usage: %s [options] [file(s)]\n"
#define CTAGS_ENVIRONMENT "CTAGS"
#define ETAGS_ENVIRONMENT "ETAGS"
#define CTAGS_FILE "tags"
#define ETAGS_FILE "TAGS"
#ifndef ETAGS
# define ETAGS "etags" /* name which causes default use of to -e */
#endif
/* The following separators are permitted for list options.
*/
#define EXTENSION_SEPARATORS "."
#define IGNORE_SEPARATORS ", \t\n"
#ifndef DEFAULT_FILE_FORMAT
# define DEFAULT_FILE_FORMAT 2
#endif
#if defined(MSDOS) || defined(WIN32) || defined(OS2) || defined(AMIGA) || defined(HAVE_OPENDIR)
# define RECURSE_SUPPORTED
#endif
/*============================================================================
= Data declarations
============================================================================*/
enum eOptionLimits {
MaxHeaderExtensions = 100, /* maximum number of extensions in -h option */
MaxSupportedTagFormat = 2
};
typedef struct sOptionDescription {
int usedByEtags;
const char *const description;
} optionDescription;
/*============================================================================
= Data definitions
============================================================================*/
static boolean StartedAsEtags = FALSE;
static const char *const CExtensionList[] = {
"c", NULL
};
static const char *const CppExtensionList[] = {
#if !defined(MSDOS) && !defined(WIN32) && !defined(OS2) && !defined(__vms)
"C", /* be careful on case-insensitive operating systems! */
#endif
"c++", "cc", "cpp", "cxx", "h", "H", "hh", "hpp", "hxx", "h++", NULL
};
static const char *const EiffelExtensionList[] = {
"e", NULL
};
static const char *const FortranExtensionList[] = {
"f", "for", "ftn", "f77", "f90", "F", "FOR", "FTN", "F77", "F90", NULL
};
static const char *const JavaExtensionList[] = {
"java", NULL
};
static const char *const HeaderExtensionList[] = {
"h", "H", "hh", "hpp", "hxx", "h++", "inc", "def", NULL
};
optionValues Option = {
{ /* include */
{ /* c */
TRUE, /* -ic */
TRUE, /* -id */
TRUE, /* -ie */
TRUE, /* -if */
TRUE, /* -ig */
FALSE, /* -im */
TRUE, /* -in */
FALSE, /* -ip */
TRUE, /* -is */
TRUE, /* -it */
TRUE, /* -iu */
TRUE, /* -iv */
FALSE, /* -ix */
FALSE, /* -iA */
FALSE /* -iC */
},
{ /* eiffel */
TRUE, /* -c */
TRUE, /* -f */
TRUE /* -l */
},
{ /* fortran */
TRUE, /* -b */
TRUE, /* -c */
TRUE, /* -e */
TRUE, /* -f */
TRUE, /* -i */
TRUE, /* -l */
TRUE, /* -m */
TRUE, /* -n */
TRUE, /* -p */
TRUE, /* -s */
TRUE /* -t */
},
{ /* java */
TRUE, /* -c */
TRUE, /* -f */
TRUE, /* -i */
TRUE, /* -m */
TRUE, /* -p */
FALSE, /* -iA */
FALSE /* -iC */
},
FALSE, /* -iF */
TRUE, /* -iS */
},
{ NULL, 0, 0 }, /* -I */
FALSE, /* -a */
FALSE, /* -B */
FALSE, /* -e */
#ifdef MACROS_USE_PATTERNS
EX_PATTERN, /* -n, --excmd */
#else
EX_MIX, /* -n, --excmd */
#endif
NULL, /* -p */
FALSE, /* -R */
TRUE, /* -u, --sort */
FALSE, /* -V */
FALSE, /* -x */
NULL, /* -L */
NULL, /* -o */
HeaderExtensionList,/* -h */
DEFAULT_FILE_FORMAT,/* --format */
FALSE, /* --if0 */
FALSE, /* --kind-long */
LANG_AUTO, /* --lang */
{ /* --langmap */
CExtensionList,
CppExtensionList,
EiffelExtensionList,
FortranExtensionList,
JavaExtensionList,
},
FALSE, /* --totals */
FALSE, /* --line-directives */
#ifdef DEBUG
0, 0 /* -D, -b */
#endif
};
/*----------------------------------------------------------------------------
- Locally used only
----------------------------------------------------------------------------*/
static optionDescription LongOptionDescription[] = {
{1," -a Append the tags to an existing tag file."},
#ifdef DEBUG
{1," -b <line>"},
{1," Set break line."},
#endif
{0," -B Use backward searching patterns (?...?)."},
#ifdef DEBUG
{1," -D <level>"},
{1," Set debug level."},
#endif
{0," -e Output tag file for use with Emacs."},
{1," -f <name>"},
{1," Output tags to the specified file (default is \"tags\"; or \"TAGS\""},
{1," if -e is specified). If specified as \"-\", tags are written to"},
{1," standard output."},
{0," -F Use forward searching patterns (/.../) (default)."},
{1," -h <list>"},
{1," Specifies a list of file extensions used for headers."},
{1," The default list is \".h.H.hh.hpp.hxx.h++\"."},
{1," -i <types>"},
{1," Nearly equivalent to --c-types=<types>."},
{1," -I <list | file>"},
{1," A list of tokens to ignore is read from either the command line,"},
{1," or the specified file (if leading character is '.', '/', or '\\')."},
{1," Particularly useful when a function definition or declaration"},
{1," contains some special macro before the parameter list."},
{1," -L <file>"},
{1," A list of source file names are read from the specified file."},
{1," If specified as \"-\", then standard input is read."},
{0," -n Equivalent to --excmd=number."},
{0," -N Equivalent to --excmd=pattern."},
{1," -o Alternative for -f."},
{1," -p <path>"},
{1," Default path to use for all (relative path) filenames."},
#ifdef RECURSE_SUPPORTED
{1," -R Equivalent to --recurse=yes."},
#else
{1," -R Not supported on this platform."},
#endif
{0," -u Equivalent to --sort=no."},
{1," -V Enable verbose messages describing actions on each source file."},
{1," -x Print a tabular cross reference file to standard output."},
{1," --append=[yes|no]"},
{1," Indicates whether tags should be appended to existing tag file"},
{1," (default=no)."},
{1," --c-types=types"},
{1," Specifies a list of C/C++ language tag types to include in the"},
{1," output file. \"Types\" is a group of one-letter flags designating"},
{1," types of tags to either include or exclude from the output. Each"},
{1," letter or group of letters may be preceded by either '+' (default,"},
{1," if omitted) to add it to those already included, or '-' to exclude"},
{1," it from the output. In the absence of any preceding '+' or '-'"},
{1," sign, only those types listed in \"types\" will be included in the"},
{1," output. Tags for the following language contructs are supported"},
{1," (types are enabled by default except as noted):"},
{1," c classes"},
{1," d macro definitions"},
{1," e enumerators (values inside an enumeration)"},
{1," f function definitions"},
{1," g enumeration names"},
{1," m class, struct, and union members [off]"},
{1," n namespaces"},
{1," p function prototypes [off]"},
{1," s structure names"},
{1," t typedefs"},
{1," u union names"},
{1," v variable definit